﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Data.SqlClient;
using Joel.Vishnu.AccesoDatos.Interfaces;

namespace Joel.Vishnu.AccesoDatos.SQL_Server
{
    public class ServicioDatosEstadoCivil : ServicioDatosBase, IServicioDatosEstadoCivil
    {
        #region Constructores

        public ServicioDatosEstadoCivil()
            : base()
        {
        }

        #endregion

        #region Metodos

        public DataSet EstadosCiviles_DevolverTodos()
        {
            try
            {
                SqlCommand cm = new SqlCommand("EstadosCiviles_DevolverTodos", Conexion);
                cm.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter da = new SqlDataAdapter(cm);
                DataSet ds = new DataSet();
                da.Fill(ds);
                return ds;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (Conexion.State == ConnectionState.Open)
                    Conexion.Close();
            }
        }

        public DataSet EstadosCiviles_DevolverPorId(Int32 estadoCivilId)
        {
            try
            {
                SqlCommand cm = new SqlCommand("EstadosCiviles_DevolverPorId", Conexion);
                cm.CommandType = CommandType.StoredProcedure;
                cm.Parameters.Add(new SqlParameter("@estadoCivilId", estadoCivilId));
                SqlDataAdapter da = new SqlDataAdapter(cm);
                DataSet ds = new DataSet();
                da.Fill(ds);
                return ds;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (Conexion.State == ConnectionState.Open)
                    Conexion.Close();
            }
        }

        #endregion
    }
}
